package router

import (
	"ginchat/docs"
	"ginchat/router/api"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)


func Router() *gin.Engine{
	r := gin.Default()

	docs.SwaggerInfo.BasePath = ""
	r.GET("/swagger/*any",ginSwagger.WrapHandler(swaggerFiles.Handler))
	r.GET("/index",api.GetIndex)

	userRouter := r.Group("/user")
	{
		userRouter.GET("/getUserList",api.GetUserList)
		userRouter.POST("/createUser",api.CreateUser)
		userRouter.DELETE("/deleteUser",api.DeleteUser)
		userRouter.POST("/updateUser",api.UpdateUser)
		userRouter.POST("/log",api.UserLog)
		userRouter.GET("/searchFriend",api.SearchFriend)
	}
	msgRouter := r.Group("/msg")
	{
		msgRouter.GET("/sending",api.SendMsg)
		//发送消息
		msgRouter.GET("/sendUserMsg",api.SendUserMsg)
		//上传文件
		msgRouter.POST("/attach/upload",api.Upload)
		//添加好友
		msgRouter.POST("/contact/addFriend",api.AddFriend)
		//创建群聊
		msgRouter.POST("/contact/createCommunity",api.CreateCommunity)
		//获取群列表
		msgRouter.POST("/contact/loadCommunity",api.Loadcomunity)
		//根据群名称加入群
		msgRouter.POST("/contact/joinGroup")
	}
	return r
}
